home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / scbench.arc / SCBIGRD.C < prev    next >
Text File  |  1980-01-01  |  1KB  |  57 lines

  1. /*
  2. ** BYTE Large File Read Benchmark
  3. ** Version 1 for 8088/8086/80286/80386
  4. ** Feb. 17, 1988
  5. ** Written in BYTE Small-C
  6. ** Based on Small-C by J.E. Hendrix
  7. **
  8. ** Routine times reading of a 1000000 byte file.
  9. **
  10. */
  11.  
  12. #include stdio.h
  13.  
  14. #define BUFSIZ 10000    /* Size of read buffer */
  15. #define LOOPS  100    /* Number of times to read BUFSIZ characters
  16.                to get 1000000 bytes read. */
  17. char *rbuff;        /* Pointer to read buffer */
  18. int tblock[4];        /* Timer block */
  19.  
  20. main()
  21. {
  22.     int i;
  23.     int fd;
  24.  
  25.     /* Announce program */
  26.     printf("BYTE Large File Read Benchmark\n\n");
  27.  
  28.     /* Now allocate (if you can) space for the read */
  29.     rbuff=malloc(BUFSIZ);
  30.     if(rbuff==NULL) {
  31.         printf("Not enough memory for rbuff\n");
  32.         exit(0);
  33.     }
  34.  
  35.     /* Open the file */
  36.     fd=fopen("BIGFILE.DAT","r");
  37.  
  38.     /* Turn on the timer */
  39.     gtime(tblock);
  40.  
  41.     /* Loop and read the file */
  42.     for(i=0;i<LOOPS;++i)
  43.         read(fd,rbuff,BUFSIZ);
  44.  
  45.     /* Turn off timer and close file */
  46.     calctim(tblock);
  47.     fclose(fd);
  48.  
  49.     /* Report results */
  50.     printf("Results: (HH:MM:SS:1/100ths)\n");
  51.     printf("Time to read file: %d:%d:%d:%d\n",tblock[0],tblock[1],
  52.      tblock[2],tblock[3]);
  53.  
  54.     exit(0);
  55. }
  56.  
  57.